const { User } = require('../models');
const UserServices = require('../services/users');

// 预留对外服务接口
class UserController {
  constructor() {
    this.userServices = new UserServices();
  }

  async getAllUsers(req, res) {
    try {
      const users = await this.userServices.getAllUsers(req.query.sort);
      res.json(users);
    } catch (err) {
      res.status(500).json({
        status: 'error',
        error: {
          code: 'INTERNAL_SERVER_ERROR',
          message: '服务器内部错误',
          details: err.message
        }
      });
    }
  }
}

module.exports = UserController;
